import org.junit.Test;/** * @Author Sunjinxu * @Date: 2022/7/13 下午1:49 * @Version 1.0 * @Description * 给定一个整数 n，求以 1 ... n 为节点组成的二叉搜索树有多少种？ */public class NumTrees {    public int numTrees(int n){        int[] dp = new int[n+1];        dp[0] = 1;        dp[1] = 1;        //注意边界条件        for (int i = 2; i < n; i++) {            for (int j = 1; j <= i; j++) {                dp[i]+=dp[j-1]*dp[i-j];            }        }        return dp[n];    }    @Test    public void numTreesTest(){        int dp = numTrees(3);        System.out.println(dp);    }}